package ecmnext.gclient.gui;


/***************************************************************/
/*                     SOFTWARE SECTION                        */
/***************************************************************/
/*
 * <p>Name: ECMNext</p>
 * <p>Description: Simulation of the platform of trading Software</p>
 * <p>Licence: General Public License</p>
 * <p>Organisation: EC Marseille</p>
 * <p>Persons involved in the project : groupE Plateforme de Trading</p>
 * <p>Current version: 1.0</p>
 */

/***************************************************************/
/*                       IMPORT SECTION                        */
/***************************************************************/

import java.awt.*;
import javax.swing.*;

import ecmnext.utils.*;

/***************************************************************/
/*             NewMessageTimer CLASS SECTION                   */
/***************************************************************/
/**
 * <p>Title : NewMessageCommTimer</p>
 * <p>Description : Text flashing when a message is received in the Communication panel</p>
 * @author Xuewen YANG ET Antoine COUDERC
 * @version 1.0
 */

public class NewMessageCommTimer
    extends Thread {
  JTabbedPane jTabbedPane;
  int index;


  public NewMessageCommTimer(JTabbedPane jTabbedPaneServerComm,int indexcomm) {

    jTabbedPane = jTabbedPaneServerComm;
    index = indexcomm;
  }


  public void run() {
    try {
        jTabbedPane.setForegroundAt(index, Color.red);
        this.sleep(400);
        jTabbedPane.setForegroundAt(index, Color.black);
        this.sleep(400);
        jTabbedPane.setForegroundAt(index, Color.red);
        this.sleep(400);
        jTabbedPane.setForegroundAt(index, Color.black);
        this.sleep(400);
        jTabbedPane.setForegroundAt(index, Color.red);
        this.sleep(400);
        if (jTabbedPane.getSelectedIndex() == index)
           jTabbedPane.setForegroundAt(index, Color.black);
         else jTabbedPane.setForegroundAt(index, Color.red);

    }
      catch (InterruptedException ex) {
        Utils.logger.warn("NewMessageCommTimer sleep interrupted. " + ex.toString());
        jTabbedPane.setForegroundAt(index, Color.black);
      }

  }
}
